package com.itheima.controller;

import com.itheima.pojo.Result;
import com.itheima.pojo.EmpLog;
import com.itheima.pojo.PageResult;
import com.itheima.service.EmpLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/log")
public class EmpLogController {

    @Autowired
    private EmpLogService empLogService;

    /**
     * 日志信息分页查询
     * 请求路径：/log/page
     * 请求方式：GET
     */
    @GetMapping("/page")
    public Result page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize) {
        log.info("日志分页查询: page={}, pageSize={}", page, pageSize);

        PageResult<EmpLog> pageResult = empLogService.queryLogs(page, pageSize);
        return Result.success(pageResult);
    }
}
